package edu.tjut.cs.domain;

import java.math.BigDecimal;

import javax.persistence.Embeddable;

@Embeddable
public class Money {
	public static final Money ZERO = new Money(0);
	
	private BigDecimal amount;

	public Money() {
	}

	public Money(int i) {
		this.amount = new BigDecimal(i);
	}

	public Money(String s) {
		this.amount = new BigDecimal(s);
	}

	public Money(BigDecimal amount) {
		this.amount = amount;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public Money add(Money other) {
		return new Money(amount.add(other.amount));
	}

	public Money subtract(Money other) {
		return new Money(amount.subtract(other.amount));
	}

	@Override
	public String toString() {
		return "Money [amount=" + amount + "]";
	}
}